package com.ttg.web.dao.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ttg.model.mapper.AdminRoleAuthMapper;
import com.ttg.model.pojo.AdminRoleAuth;
import com.ttg.web.dao.AdminRoleAuthDao;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author ZQ
 * @version 1.0
 * @Description
 * @date 2021/1/27 10:18
 */
@Service
public class AdminRoleAuthDaoImpl extends ServiceImpl<AdminRoleAuthMapper, AdminRoleAuth> implements AdminRoleAuthDao {




    @Override
    public boolean deleteAuthIdByRoleId(Long roleId) {
        LambdaQueryWrapper<AdminRoleAuth> wrapper = new LambdaQueryWrapper<AdminRoleAuth>();
        wrapper.eq(AdminRoleAuth::getAraRoleId,roleId);
        return remove(wrapper);
    }

    @Override
    public boolean saveAuthId(AdminRoleAuth adminRoleAuth) {
        return save(adminRoleAuth);
    }

    @Override
    public List<AdminRoleAuth> selectByRoleIds(List<Long> araRoleIds) {
        if(CollectionUtils.isEmpty(araRoleIds)){
            return null;
        }
        LambdaQueryWrapper<AdminRoleAuth> wrapper = new LambdaQueryWrapper<AdminRoleAuth>();
        wrapper.in(AdminRoleAuth::getAraRoleId, araRoleIds);
        return list(wrapper);
    }

}
